home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HPAVC
/
HPAVC CD-ROM.iso
/
CIREL.ZIP
/
EFFECT.BAK
< prev
next >
Wrap
Text File
|
1995-05-11
|
2KB
|
106 lines
#include <stdio.h>
#include <conio.h>
#include <math.h>
#pragma inline //Allows to use 386 code
void hor(int x,int y,int x1,char col) // Draws one horizontal line
{
int temp;
if(x>x1){
temp=x;
x=x1;
x1=temp;
}
asm{
mov ax,0a000h
mov es,ax
mov ax,320
mov bx,y
mul bx
add ax,x
mov di,ax
mov cx,x1
sub cx,x
mov al,col
rep stosb
}
}
void Circle(int x,int y,int r,int col)
{
int i,xx,lx=r;
for(i=0;i<r+1;i++){ //Repeats only one quarter
xx=sqrt((r*r)-(i*i)); //This is the circle engine (not the fastest one but it works)
//Look more info from ceh.doc
hor(x+xx,y+i,lx+x+1,col);
hor(x+xx,y-i,lx+x+1,col);
hor(x-xx,y+i,-lx+x-1,col);
hor(x-xx,y-i,-lx+x-1,col);
lx=xx;
}
}
void Ellipse(int x,int y,int a,int b,int col)
{
int i,xx,lx=a;
for(i=0;i<b+1;i++){
xx=sqrt((double)(a*a)*((b*b)-(i*i)));
xx=xx/b;
hor(x+xx,y+i,lx+x+1,col);
hor(x+xx,y-i,lx+x+1,col);
hor(x-xx,y+i,-lx+x-1,col);
hor(x-xx,y-i,-lx+x-1,col);
lx=xx;
}
}
void Hyperbeli(int x,int y,int a,int b,int col)
{
int i,xx,lx=a;
for(i=0;i<b+1;i++){
xx=sqrt((double)(a*a)*((b*b)+(i*i)));
xx=xx/b;
hor(x+xx,y+i,lx+x+3,col);
hor(x+xx,y-i,lx+x+3,col);
hor(x-xx,y+i,-lx+x-3,col);
hor(x-xx,y-i,-lx+x-3,col);
lx=xx;
}
}
void Clr()
{
asm{
mov ax,0a000h
mov es,ax
xor ax,ax
xor di,di
mov cx,16000
rep stosd
}
}
int main(void)
{
int i;
asm mov ax,13h // Puts 320*200*256 Mode on
asm int 10h
Circle(160,100,5,1);
getch();
for(i=0;i<90;i++){
Circle(160,100,i+5,i+1);
}
getch();Clr();
Ellipse(160,100,10,5,1);
getch();
for(i=0;i<40;i++){
Ellipse(160,100,i*2+10,i+5,i+1);
}
getch();Clr();
Hyperbeli(160,100,10,5,1);
getch();
for(i=0;i<40;i++){
Hyperbeli(160,100,i*2+10,i+5,i+1);
}
getch();
asm mov ax,03 //Puts text mode back
asm int 10h
return 0;
}